<?php

/**
 * Description of Apartment
 *
 * @author Carlos
 */
class ApartmentController extends BaseController {
    
        public function showApartment($fecha, $id){

            $apartment = Apartment::active()
                    ->where('fecha', $fecha)
                    ->with('imagesOrdered')
                    ->find($id);

            if( is_null($apartment)) {
                App::abort(404);
            }

            $images = $apartment->imagesOrdered;

            $otrosApartments = Apartment::active()
                    ->where('id', '<>', $apartment->id)
                    ->orderBy('fecha', 'desc')
                    ->get();

            return View::make('apartment', compact('apartment', 'images', 'otrosApartments'));
    }
}
